//
//  EFGoodsDetailViewCellAttribute.m
//  EnjogFood
//
//  Created by guocheng on 2017/5/21.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFGoodsDetailViewCellAttribute.h"
#import "EFGoodsDetailViewItemAttribute.h"

@interface EFGoodsDetailViewCellAttribute()

@property(strong,nonatomic)UILabel* nameLabel;
@property(strong,nonatomic)UILabel* contentLabel;
@property(strong,nonatomic)UIView* lineView;

@end

@implementation EFGoodsDetailViewCellAttribute



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor whiteColor];
        [self initView];
    }
    return self;
}

+(CGFloat)cellHeight:(EFGoodsDetailViewItemAttribute*)item{
    
    CGFloat height = 25;
    
    UILabel *tempLabel = [[UILabel alloc] init];
    tempLabel.font = [UIFont systemFontOfSize:13];
    tempLabel.numberOfLines = 0;
    tempLabel.text = item.content;
    
    tempLabel.width = kScreenWidth - 81 - 21;
    [tempLabel sizeToFit];
    
    CGFloat labelHeight = tempLabel.height;
    
    return height + labelHeight;
}

-(void)setObject:(EFGoodsDetailViewItemAttribute *)item{
    [self.nameLabel setText:item.name];
    [self.nameLabel sizeToFit];
    
    self.nameLabel.top = 10;
    self.nameLabel.left = 20;
    
    [self.contentLabel setText:item.content];
    [self.contentLabel sizeToFit];
    
    self.contentLabel.top = 10;
    self.contentLabel.left = 81;
    
    self.lineView.left = 20;
    self.lineView.top = self.contentLabel.bottom +  10;
}

-(void)initView{
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.contentLabel];
    [self.contentView addSubview:self.lineView];
}
 

-(UILabel *)nameLabel{
    if(_nameLabel == NULL){
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.font = [UIFont systemFontOfSize:13];
        _nameLabel.textColor  = kBlack999;
    }
    return _nameLabel;
}

-(UILabel *)contentLabel{
    if(_contentLabel == NULL){
        _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 81 - 21, 0)];
        _contentLabel.font = [UIFont systemFontOfSize:13];
        _contentLabel.textColor  = kBlack333;
        _contentLabel.numberOfLines = 0;
    }
    return _contentLabel;
}



-(UIView*)lineView{
    if(_lineView == NULL){
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth - 40, 1)];
        _lineView.backgroundColor = kBlackDDD;
        
    }
    return _lineView;
}

@end
